﻿using System.Web;
using PaceR.Core.EntityStorage;

namespace PaceR.Web.EntityStorage
{
    public sealed class CacheStorage : EntityStore
    {
        protected override object GetEntity(string storageKey)
        {
            return HttpContext.Current.Cache.Get(storageKey);
        }

        protected override void SaveEntity(string storageKey, object entity)
        {
            HttpContext.Current.Cache.Insert(storageKey, entity);
        }

        protected override void ClearEntity(string storageKey)
        {
            if (GetEntity(storageKey) != null)
                HttpContext.Current.Cache.Remove(storageKey);
        }
    }
}
